import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:state_management_flutter_bloc/bloc/palyer_listing_bloc.dart';
import 'package:state_management_flutter_bloc/bloc/player_listing_events.dart';
import 'package:state_management_flutter_bloc/themes/themes.dart';

class SearchBar extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 16),
      decoration: BoxDecoration(
        color: Colors.black12,
        borderRadius: BorderRadius.all(Radius.circular(20.0)),
      ),
      child: TextField(
        onChanged:(value){
          BlocProvider.of<PlayerListingBloc>(context).dispatch(SearchTextChangedEvent(searchTerm: value));
        },
        style: searchTextStyle,
        decoration: InputDecoration(
          border: InputBorder.none,
          contentPadding: EdgeInsets.symmetric(horizontal:8.0,vertical: 8.0),
          hintStyle: hintStyle,
          hintText: '查找球员',
          prefixIcon: Icon(Icons.person,size:30.0,color:Colors.black,)
        ),
      ),
    );
  }
}
